package com.xxzx.journalism.controller;

import com.xxzx.journalism.model.common.ResultModel;
import com.xxzx.journalism.model.vo.user.UserParamsVO;
import com.xxzx.journalism.model.vo.user.UserVO;
import com.xxzx.journalism.util.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户接口 - 用户
 */
@RequestMapping(path = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@Slf4j
public class UsersController {
    /**
     * 登录用户
     *
     * @return
     */
    @PostMapping("/login")
    public ResponseEntity<ResultModel<String>> login(@Valid @RequestBody UserParamsVO vo) throws Exception {
        ResultModel<String> ret = new ResultModel<>();
        // todo 具体逻辑待实现
        if (vo.getAccount().equals("admin") && vo.getPassword().equals("21232f297a57a5a743894a0e4a801fc3")) {
            ret.setData("token_todo");
        } else {
            ret.setRetcode(400);
            ret.setMsg("Incorrect user or password.");
        }
        return ResultUtils.result(ret);
    }
}

